package com.gxuwz.service;

import com.gxuwz.mapper.DepartmentMapper;
import com.gxuwz.model.entity.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;

    // 根据 depID 查询二级学院
    public Department getDepartmentByDepID(String depID) {
        return departmentMapper.selectDepartmentByDepID(depID);
    }

    // 根据 depName 查询二级学院
    public Department getDepartmentByDepName(String depName) {return departmentMapper.selectDepartmentByDepName(depName); }

    // 根据 ID 查询二级学院
    public Department getDepartmentByID(int ID) {return departmentMapper.selectDepartmentByID(ID); }

    // 更新二级学院信息
    public boolean updateDepartment(Department department) {
        return departmentMapper.updateDepartment(department) > 0;
    }

    // 添加新的二级学院
    public boolean addDepartment(Department department) {
        return departmentMapper.insertDepartment(department) > 0;
    }

    // 根据 ID 删除二级学院
    public boolean deleteDepartmentByDepID(String ID) {
        return departmentMapper.deleteDepartmentByID(ID) > 0;
    }

    // 查询所有二级学院
    public List<Department> getAllDepartments() {
        return departmentMapper.getAllDepartment();
    }
}
